<?php

class ShowPremiumPage extends AbstractPage
{
	public static $requireModule = MODULE_RESSOURCE_LIST;

	function __construct() 
	{
		parent::__construct();
	}
	
	function show()
	{
		global $USER, $PANET;
		
		$st_out = $USER["prem_time"]-TIMESTAMP;
		
		$this->tplObj->assign_vars(array(
			'st_out'	=> $st_out,
			'atm'		=> $USER['atm'],
		));
		$this->display('page.premium.tpl');
	}
	
	function h1()
	{
		global $LNG, $resource, $USER, $PLANET;
		
		if($USER["atm"]<3500)
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			return;
		}
		
		$USER['atm'] -= 3500;
		$tim = max(0, $USER["prem_time"]-TIMESTAMP);					
		$time=TIMESTAMP+86400+$tim;
					
		$SQLQuery	=  "UPDATE ".USERS." SET
									`prem_time` = '".$time."' 
									WHERE `id` = '".$USER["id"]."';";
		$GLOBALS['DATABASE']->query($SQLQuery);
		
		$this->printMessage('Премиум аккаунт успешно оплачен.',true,  array("game.php?page=premium", 1));
	}
	
	function h2()
	{
		global $USER;
		
		if($USER["atm"]<15000)
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			return;
		}
		
		$USER['atm'] -= 15000;
		$tim = max(0, $USER["prem_time"]-TIMESTAMP);					
		$time=TIMESTAMP+604800+$tim;
					
		$SQLQuery	=  "UPDATE ".USERS." SET
									`prem_time` = '".$time."' 
									WHERE `id` = '".$USER["id"]."';";
		$GLOBALS['DATABASE']->query($SQLQuery);
			
		$this->printMessage('Премиум аккаунт успешно оплачен.',true,  array("game.php?page=premium", 1));
	}
	function h3()
	{
		global $USER;
		
		if($USER["atm"]<45000)
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			return;
		}
		
		$USER['atm'] -= 45000;
		$tim = max(0, $USER["prem_time"]-TIMESTAMP);					
		$time=TIMESTAMP+2678400+$tim;
					
		$SQLQuery	=  "UPDATE ".USERS." SET
									`prem_time` = '".$time."' 
									WHERE `id` = '".$USER["id"]."';";
		$GLOBALS['DATABASE']->query($SQLQuery);
			
		$this->printMessage('Премиум аккаунт успешно оплачен.',true,  array("game.php?page=premium", 1));
	}
	function h4()
	{
		global $USER;
		
		if($USER["atm"]<120000)
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			return;
		}
		
		$USER['atm'] -= 120000;
		$tim = max(0, $USER["prem_time"]-TIMESTAMP);					
		$time=TIMESTAMP+8035200+$tim;
					
		$SQLQuery	=  "UPDATE ".USERS." SET
									`prem_time` = '".$time."' 
									WHERE `id` = '".$USER["id"]."';";
		$GLOBALS['DATABASE']->query($SQLQuery);
			
		$this->printMessage('Премиум аккаунт успешно оплачен.',true,  array("game.php?page=premium", 1));
	}
	function h5()
	{
		global $USER;
		
		if($USER["atm"]<200000)
		{
			header("Location: ".$_SERVER['HTTP_REFERER']);
			return;
		}
		
		$USER['atm'] -= 200000;
		$tim = max(0, $USER["prem_time"]-TIMESTAMP);					
		$time=TIMESTAMP+16070400+$tim;
					
		$SQLQuery	=  "UPDATE ".USERS." SET
									`prem_time` = '".$time."' 
									WHERE `id` = '".$USER["id"]."';";
		$GLOBALS['DATABASE']->query($SQLQuery);
			
		$this->printMessage('Премиум аккаунт успешно оплачен.',true,  array("game.php?page=premium", 1));
	}
	
}
?>